package com.example.demo.admin.test.concurrent;/**
 * Created by kete on 2018-09-26.
 */

import com.beust.jcommander.internal.Lists;

import java.math.BigDecimal;
import java.util.List;

/**
 * 作者：kete
 * 创建时间：2018-09-26 11:09
 * 功能描述：
 * 版本：
 */
public class TwoThread {
    private volatile int num =1;

    public static void main(String[] args) {

        List<String> list = Lists.newArrayList("10","-6","-9","20","30");

        BigDecimal custom = BigDecimal.ZERO;


        for(String s : list){
            custom = custom.add(new BigDecimal(s));
        }

        System.out.println(custom.toString());


//        TwoThread thread = new TwoThread();
//        Thread thread1 = new Thread(thread.new ji());
//        Thread thread2 = new Thread(thread.new ou());
//        thread1.start();
//        thread2.start();

//        try {
//            thread1.join();
//            thread2.join();
//        }catch (InterruptedException e){
//            e.printStackTrace();
//        }
    }


    class ou implements Runnable{
        @Override
        public void run() {
            while (num<=1000){
                if(num%2==0){
                    System.out.println("thread"+Thread.currentThread().getName()+"-- ou :"+num);
                    num++;
                }
            }
        }

    }

    class ji implements Runnable{
        @Override
        public void run() {
            while (num<=1000){
                if(num%2==1){
                    System.out.println("thread"+Thread.currentThread().getName()+"-- ji :"+num);
                    num++;
                }
            }
        }
    }

}
